package com.xucy.springboot.designmodel.behavioral.observer;

/**
 * @Author xucy  Observer观察者  Observable被观察者  Event EventListener
 * @Date 2019-07-28 11:15
 * @Description 观察者模式
 *   应用场景：
 *     老师有负责的课程，老师观察课程，如果有人提问题，那就通知老师
 **/

public class Test {
    public static void main(String[] args) {
        Question question=new Question("小李","反射是啥意思？");


        Course course=new Course("java");

        Teacher teacher=new Teacher("小徐老师");

        Teacher teacher1=new Teacher("小杨老师");

        course.addObserver(teacher);
        course.addObserver(teacher1);

        course.commitQuestion(course,question);
    }
}
